import {postForm, postJSON} from '@/common/utils/request.ts'

const SYS_CAPTCHA = '/manage/system/captcha'

const SYS_MSG = '/manage/system/msg'

const SYS_ROLE = '/manage/system/role'

const SYS_MENU = '/manage/system/menu'

const SYS_ORG = '/manage/system/org'

const SYS_USER = '/manage/system/user'

const SYS_DICT = '/manage/system/dict'

/** 角色 **/
//全部由我创建的角色
export function apiAllMyCreateRole() {
    return postForm(`${SYS_ROLE}/allMyRole`, {})
}

// 角色分页数据
export function apiRolePage(param) {
    return postForm(`${SYS_ROLE}/pageMyRole`, param)
}

//插入数据
export function apiRoleInsert(param = {}) {
    return postForm(`${SYS_ROLE}/insertRole`, param)
}

export function apiRoleDelete(param = {}) {
    return postForm(`${SYS_ROLE}/deleteRole`, param)
}

export function apiRoleUpdate(param = {}) {
    return postForm(`${SYS_ROLE}/updateRole`, param)
}

export function apiRoleMenuUpdate(param = {}) {
    return postForm(`${SYS_ROLE}/updateRoleMenu`, param)
}

/** 菜单 **/
//刷新缓存
export function apiMenuRefreshCache(param = {}) {
    return postForm(`${SYS_MENU}/refreshMenuCache`, param)
}

//插入菜单
export function apiMenuInsert(param = {}) {
    return postForm(`${SYS_MENU}/insertMenu`, param)
}

//全部菜单
export function apiUserHasMenu(param = {}) {
    return postForm(`${SYS_MENU}/userHasMenu`, param)
}

//修改菜单
export function apiMenuUpdate(param = {}) {
    return postForm(`${SYS_MENU}/updateMenu`, param)
}

//修改菜单
export function apiMenuDelete(param = {}) {
    return postForm(`${SYS_MENU}/deleteMenu`, param)
}

/** 用户 **/
// 添加用户
export function apiUserInsert(param = {}) {
    return postForm(`${SYS_USER}/insert`, param)
}

// 修改用户信息
export function apiUserUpdate(param = {}) {
    return postForm(`${SYS_USER}/update`, param)
}

// 删除用户信息
export function apiUserDelete(param = {}) {
    return postForm(`${SYS_USER}/delete`, param)
}

// 登录
export function apiUserLogin(param = {}) {
    return postForm(`${SYS_USER}/managePwdLogin`, param)
}

// 注册
export function apiUserRegisterPhone(param = {}) {
    return postForm(`${SYS_USER}/registerPhone`, param)
}

// 注册
export function apiUserRegisterEmail(param = {}) {
    return postForm(`${SYS_USER}/registerEmail`, param)
}


// 获取用户详细信息
export function apiUserInfo(param = {}) {
    return postForm(`${SYS_USER}/userInfo`, param)
}

//用户分页数据
export function apiUserPage(param = {}) {
    return postForm(`${SYS_USER}/page`, param)
}

// 获取验证码
export function apiLoginCaptchaImg() {
    return postForm(`${SYS_CAPTCHA}/loginCaptchaImg`)
}

export function apiResetUserPassword(param = {}) {
    return postForm(`${SYS_USER}/resetUserPassword`, param)
}

export function apiResetMyPassword(param = {}) {
    return postForm(`${SYS_USER}/resetMyPassword`, param)
}

/**
 * 字典
 */
//刷新缓存
export function apiDictInsert(param = {}) {
    return postForm(`${SYS_DICT}/insert`, param)
}

export function apiDictUpdate(param = {}) {
    return postForm(`${SYS_DICT}/update`, param)
}

export function apiDictDelete(param = {}) {
    return postForm(`${SYS_DICT}/delete`, param)
}

export function apiDictPage(param = {}) {
    return postForm(`${SYS_DICT}/page`, param)
}

export function apiDictOptionEnumAll(param = {}) {
    return postForm(`${SYS_DICT}/allDictOptionEnum`, param)
}

export function apiDictOptionEnumValue(param = {}) {
    return postForm(`${SYS_DICT}/dictOptionEnumValue`, param)
}

export function apiDictClearCache(param = {}) {
    return postForm(`${SYS_DICT}/clearCache`, param)
}

//修改配置信息
export function apiSettingUpdate(param = {}) {
    return postJSON(`${SYS_DICT}/updateSetting`, param)
}

export function apiSettingSelect(param = {}) {
    return postForm(`${SYS_DICT}/selectSetting`, param)
}

// 分页获取文件列表
export function apiFilePage(param = {}) {
    return postForm('/manage/file/page', param)
}

//
export function apiSysMsgUserPageData(param = {}) {
    return postForm(`${SYS_MSG}/userPageData`, param)
}

export function apiSysMsgPageData(param = {}) {
    return postForm(`${SYS_MSG}/msgPageData`, param)
}

export function apiSysMsgInsert(param = {}) {
    return postForm(`${SYS_MSG}/insert`, param)
}

export function apiSysMsgDelete(param = {}) {
    return postForm(`${SYS_MSG}/delete`, param)
}

export function apiSysMsgTopList(param = {}) {
    return postForm(`${SYS_MSG}/msgTopList`, param, {}, {closeError: '1'},)
}

export function apiSysGetRegisterCaptcha(param = {}) {
    return postForm(`${SYS_CAPTCHA}/emailRegister`, param)
}

export function apiSysMsgReadAll(param = {}) {
    return postForm(`${SYS_MSG}/readAll`, param)
}

export function apiSysMsgReadBatch(param = {}) {
    return postForm(`${SYS_MSG}/readBatch`, param)
}

/**
 * 组织机构
 */
//全部部门
export function apiUserHasOrg(param = {}) {
    return postForm(`${SYS_ORG}/userHasOrg`, param)
}

//刷新部门缓存
export function apiOrgRefreshCache(param = {}) {
    return postForm(`${SYS_ORG}/refreshOrgCache`, param)
}

//插入部门信息
export function apiOrgInsert(param = {}) {
    return postForm(`${SYS_ORG}/insertOrg`, param)
}

//修改部门信息
export function apiOrgUpdate(param = {}) {
    return postForm(`${SYS_ORG}/updateOrg`, param)
}

//删除部门信息
export function apiOrgDelete(param = {}) {
    return postForm(`${SYS_ORG}/deleteOrg`, param)
}
